/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.nattakute.model;

import java.io.Serializable;
import java.util.Set;

import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.codehaus.jackson.annotate.JsonBackReference;
import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.annotate.JsonManagedReference;

/**
 *
 * @author simple7211
 */
@Entity
@Table(name = "lab")

public class Lab implements Serializable {
	
    
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "labID")
    private Integer labId;
    
    @Basic(optional = false)
    @Column(name = "labName")
    private String labName;
    
    @JsonBackReference
    @JoinColumn(name = "departmentId", referencedColumnName = "departmentId")
    @ManyToOne(fetch = FetchType.EAGER)
    private Department department;

    @JsonManagedReference
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "lab", fetch = FetchType.LAZY)
    private Set<Resource> resources;
	
	@JsonManagedReference
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "lab", fetch = FetchType.LAZY)
    private Set<Timetable> timetables;
    
    public Lab() {
    }

    public Lab(Integer labId) {
        this.labId = labId;
    }

    public Lab(Integer labId, String labName) {
        this.labId = labId;
        this.labName = labName;
    }

    
    public Integer getLabId() {
		return labId;
	}

	public void setLabId(Integer labId) {
		this.labId = labId;
	}

	public String getLabName() {
        return labName;
    }

    public void setLabName(String labName) {
        this.labName = labName;
    }

    
    @JsonIgnore
    public Set<Timetable> getTimetables() {
		return timetables;
	}

	public void setTimetables(Set<Timetable> timetables) {
		this.timetables = timetables;
	}

	public Department getDepartment() {
		return department;
	}

	public void setDepartment(Department department) {
		this.department = department;
	}

	@Override
    public int hashCode() {
        int hash = 0;
        hash += (labId != null ? labId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Lab)) {
            return false;
        }
        Lab other = (Lab) object;
        if ((this.labId == null && other.labId != null) || (this.labId != null && !this.labId.equals(other.labId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "javaapplication1.Lab[ labID=" + labId + " ]";
    }

    @JsonIgnore
	public Set<Resource> getResources() {
		return resources;
	}

	public void setResources(Set<Resource> resources) {
		this.resources = resources;
	}

   
   

    
}
